import { createStore } from 'vuex';
const setCache = (store) => {
    store.subscribe((mutation, state) => {
        localStorage.setItem('vuexCache', JSON.stringify(store.state))
    })
}
var vuexCache = localStorage.getItem('vuexCache')
const store = createStore({
    plugins: [setCache],
    state: vuexCache ? JSON.parse(vuexCache) : {
        defaultActive: '/overview',
        sidebarCollapse: false,
        loginData: null
    },
    mutations: {
        setDefaultActive(state, val) {
            state.defaultActive = val
        },
        setSidebarCollapse(state) {
            state.sidebarCollapse = !state.sidebarCollapse
        },
    }
})
export default store